﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="~/Content/jquery-easyui-1.9.4/themes/metro/easyui.css" rel="stylesheet" />
    <link href="~/Content/scripts/jquery-easyui-extensions/datagrid/datagrid.css" rel="stylesheet" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/layui/css/layui_extension.css" rel="stylesheet" />
    <link href="~/Content/jquery-easyui-1.9.4/themes/icon.css" rel="stylesheet" />
    <link href="~/Content/960css/960.css" rel="stylesheet" />
    <link href="~/Content/scripts/jquery-plugin/showloading/showLoading.css" rel="stylesheet" />
    <link href="~/Content/icon/icon.css" rel="stylesheet" />
    <link href="~/Content/css/Index.css" rel="stylesheet" />
    <link href="~/Content/css/Dialog.css" rel="stylesheet" />
    <link href="~/Content/css/com.css" rel="stylesheet" />
    <link href="~/Content/css/font_whut/iconfont.css" rel="stylesheet" />
    <link href="~/Content/css/fontAwesome/css/fontAwesome.css" rel="stylesheet" />


    <script src="~/Content/jquery-easyui-1.9.4/jquery.min.js"></script>
    <script src="~/Content/jquery-easyui-1.9.4/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.9.4/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Content/scripts/jquery-plugin/jquery.cookie.js"></script>
    <script src="~/Content/scripts/jquery-easyui-extensions/jquery.jdirk.js"></script>
    <script src="~/Content/scripts/jquery-easyui-extensions/jeasyui.extensions.validatebox.js"></script>
    <script src="~/Content/scripts/jquery-easyui-extensions/menu/jeasyui.extensions.menu.js"></script>
    <script src="~/Content/scripts/jquery-easyui-extensions/datagrid/getColumnInfo.js"></script>
    <script src="~/Content/scripts/jquery-easyui-extensions/datagrid/columnToggle.js"></script>
    <script src="~/Content/scripts/Common/datetools.js"></script>
    <script src="~/Content/scripts/Common/utils.js"></script>
    <script src="~/Content/scripts/Common/common.js"></script>
    <script src="~/Content/scripts/jquery-plugin/showloading/jquery.showLoading.js"></script>
    <script src="~/Content/scripts/Common/StaticComboModel.js"></script>
    <script src="~/Content/layui/layui.all.js"></script>
    <script src="~/Content/css/font_whut/iconfont.js"></script>
    <script src="//at.alicdn.com/t/font_1777012_1n4cykfog9x.js"></script>
    <script src="~/Content/scripts/Common/fileUpLoad.js"></script>
    <script type="text/javascript">
        $(function () {
            //根据请求参数选择打开的Tab面板
            var action = com.get.action;
            var tabSelect;
            $("#revTab").tabs({
                fit: true,
                selected: tabSelect,
                tools: [{ iconCls: 'icon-accept', text: '同意', handler: Agree, id: 'Agree' },
                    { iconCls: 'icon-cancel', text: '不同意', handler: disAgree, id: 'disAgree' },
                    { iconCls: 'icon-save', text: '提交', handler: Submit, id: 'submit' },
                    { iconCls: 'panel-tool-close', text: '关闭', handler: Close }]
            });
            if (action == "view") {
                $("#disAgree").linkbutton("disable");
                $("#Agree").linkbutton("disable");
                $("#submit").linkbutton("disable");
                tabSelect = 0;
            }
            else if (com.get.action == "addReview") {
                tabSelect = 1;
                $("#Agree").linkbutton("disable");
                $("#disAgree").linkbutton("disable");
                $("img[name=imgDelete]").each(function (index) {
                    if ($(this).attr("attrcandelete") == "1") {
                        $(this).show()
                        $(this).click(function () {
                            $(this).parent().parent().parent().parent().remove();
                        });
                    }
                });
            }
            else if (com.get.action == "review") {
                $("#submit").linkbutton("disable");
                tabSelect = 0;
            }
            else {
                tabSelect = 0;
            }
        })
        function Submit() {
            if (action == "addReview") {
                var data = com.serializeObj("reviewForm1");
                data.RevId = $("#reviewTotalID").val();
                com.ajax({
                    data: data, url: "/Audit/BeginReview", success: function (data) {
                        com.message(data.state, data.msg, function () {
                            if (data.state == "success") {
                                var torefresh = unescape(com.get.torefresh);
                                parent.wrapper.tabClosethisRefreshByTitle(torefresh);
                            }
                        })
                    }
                });
            }

        }
        function Close() {
            parent.wrapper.tabCurrentClose();
        }
        function Agree() {
            var data = { RevId: $("#reviewTotalID").val(), RevPeoId: $("#basicId").val(), RevPeoName: $("#basicName").val(), RevResult: "1", RevAdv: $("#txtCurrentAdv").val() };
            com.ajax({
                data: data, url: "/Audit/SubmitReview",
                success: function (data) {
                    com.message(data.state, data.msg, function () {
                        parent.wrapper.tabClosethisRefreshByTitle("我的桌面");
                    })
                }
            });
        }
        function disAgree() {
            var data = { RevId: $("#reviewTotalID").val(), RevPeoId: $("#basicId").val(), RevPeoName: $("#basicName").val(), RevResult: "2", RevAdv: $("#txtCurrentAdv").val() };
            com.ajax({
                data: data, url: "/Audit/SubmitReview",
                success: function (data) {
                    com.message(data.state, data.msg, function () {
                        parent.wrapper.tabClosethisRefreshByTitle("我的桌面");
                    })
                }
            });
        }
    </script>
</head>
<body style="padding: 1px; height: 100%">
    <div id="divTotal" style="height:99.4%; width:99.6%; margin: 1px; position: absolute; overflow: hidden;">
        <div id="revTab">
            <div title="信息列表" style="padding: 10px;">
                @RenderBody()
            </div>
            <div title="审批明细" style="overflow: auto; padding: 10px;">
                <div id="reviewMaster" class="container_16" style="height: auto;">
                    @{
                        int i = 0;
                        List<PMS.BD_btnPermission> btnPerm = null;
                        PMS.BD_ReviewTotal reviewTotal;
                        List<PMS.BD_ReviewDetail> reviewDetail;
                        List<PMS.BD_ReviewDetail> detailLow;
                        List<PMS.BD_ReviewDetail> detailHigh;
                        List<string> groupLow = new List<string>();
                        List<string> groupHigh = new List<string>();
                        PMS.UserInfo basic = PMS.OperateContext.sessUserInfo;
                        string action = Request.QueryString["action"];
                        int reviewId = PMS.Commons.String2Int32(Request.QueryString["reviewId"]);
                        reviewTotal = PMS.BLLSession.Current.BD_ReviewTotalBLL.GetListBy(r => r.ID == reviewId).FirstOrDefault();
                        reviewDetail = PMS.BLLSession.Current.BD_ReviewDetailBLL.GetListBy(r => r.ReviewerId == reviewId, r => r.RevGroup, true).ToList();
                        detailLow = reviewDetail.Where(r => r.IsLeadOrDep == "0").ToList();
                        detailHigh = reviewDetail.Where(r => r.IsLeadOrDep == "1").OrderBy(r => r.RevGroup).ToList();
                        detailLow.ForEach(r => { if (!groupLow.Contains(r.RevGroup)) { groupLow.Add(r.RevGroup); } });
                        detailHigh.ForEach(r => { if (!groupHigh.Contains(r.RevGroup)) { groupHigh.Add(r.RevGroup); } });
                    }
                    <form id="reviewForm1">
                        <div class="grid_16">
                            <h1 style="font-size:12px;font-family: helvetica,tahoma,verdana,sans-serif;display: block;font-weight: bold;">审批单号：@reviewTotal.RevNum</h1>
                            <input type="hidden" id="reviewTotalID" value="@(reviewTotal.ID)">
                            <input type="hidden" id="basicId" value="@(basic.Id)">
                            <input type="hidden" id="basicName" value="@(basic.Name)">
                        </div>
                        <div class="grid_16" style="font-size: 12px;font-family: helvetica,tahoma,verdana,sans-serif;">
                            <table style="width: 100%; border: solid; border-color: #BCBCBC">
                                <tr>
                                    <td style="width: 500px; border: solid; border-color: #BCBCBC">
                                        <table>
                                            <tr>
                                                <td rowspan="2" style="width: 100px">
                                                    制单信息
                                                </td>
                                                <td></td>
                                                <td style="width: 120px">
                                                    制单人：
                                                    @reviewTotal.AddPerson
                                                </td>
                                                <td style="width: 200px">
                                                    制单时间：
                                                    @reviewTotal.FillDate
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="width: 100px">
                                                    制单意见：
                                                </td>
                                                <td style="text-align: left" colspan="3">
                                                    <textarea style="height: 40px; width: 620px" id="AddPerAdv" name="AddPerAdv" @if (action != "addReview") { @Html.Raw("readonly='readonly'")}>@reviewTotal.AddPerAdv</textarea>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            <table style="width: 100%; border: solid; border-color: #BCBCBC">
                                @foreach (var subgroup in groupLow)
                                {
                                    i++;
                                    <tr>
                                        <td style="width: 500px; border: solid; border-color: #BCBCBC">
                                            @{var grouplist = detailLow.Where(r => r.RevGroup == subgroup);}
                                            @foreach (var sub in grouplist)
                                            {
                                                <table style="width: 100%">
                                                    <tr>
                                                        <td rowspan="2" style="width: 100px">
                                                            @sub.RankName
                                                        </td>
                                                        <td></td>
                                                        <td style="width: 150px">
                                                            审批人：
                                                            @if (action == "addReview")
                                                            {
                                                                <input id="per@(sub.ID)" style="width: 80px" class="easyui-combobox" name="per@(sub.ID)"
                                                                       data-options="@Html.Raw("valueField:'value',textField:'text',url:'/Audit/GetAuditPeo?type=low&detailId=" + sub.DocNum + "',panelHeight: 'auto',editable: false, onLoadSuccess: function () {var data =$('#per" + sub.ID + "').combobox('getData');if (data.length>0) {console.log("+sub.Reviewer+");if(" + sub.Reviewer + "!=0){ $('#per" + sub.ID + "').combobox('select'," + sub.Reviewer + ");}else{ if(data.length>=1){ console.log('123');$('#per" + sub.ID + "').combobox('select', data[0].value);}}}}")" />
                                                            }
                                                            else
                                                            {
                                                                @sub.ReviewerName
                                                            }
                                                        </td>
                                                        <td style="width: 120px">
                                                            审批结果：
                                                            @if (sub.RevState == "0")
                                                            {
                                                                @Html.Raw("未审批")
                                                            }
                                                            else if (sub.RevState == "1")
                                                            {
                                                                @Html.Raw("同意")
                                                            }
                                                            else if (sub.RevState == "2")
                                                            {
                                                                @Html.Raw("驳回")
                                                            }
                                                            else
                                                            {
                                                                @Html.Raw("")
                                                            }
                                                        </td>
                                                        <td>
                                                            审批时间:@sub.RevTime
                                                        </td>
                                                        <td style="width: 150px">
                                                            @if (sub.IsAuth == "1")
                                                            {
                                                                //被授权人:sub.AuthName;
                                                            }
                                                        </td>
                                                        <td style="text-align: right;">
                                                            <img src="/Content/icon/icon/DeleteRed.png" style="cursor: pointer; display: none" id="imgDelete" name="imgDelete" attrcandelete="@(sub.CanDelete)" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 100px">
                                                            审批意见：
                                                        </td>
                                                        <td style="text-align: left;" colspan="4">
                                                            <textarea style="height: 40px; width: 620px;" readonly="readonly">@sub.RevAdv</textarea>
                                                        </td>
                                                        <td></td>
                                                    </tr>
                                                </table>
                                            }
                                        </td>
                                    </tr>
                                }
                            </table>
                            <table style="width: 100%; border: solid; border-color: #BCBCBC">
                                @foreach (var subgroup in groupHigh)
                                {
                                    i++;
                                    <tr>
                                        <td style="width: 500px; border: solid; border-color: #BCBCBC">
                                            @{var grouplist = detailHigh.Where(r => r.RevGroup == subgroup);}
                                            @foreach (var sub in grouplist)
                                            {
                                                <table>
                                                    <tr>
                                                        <td rowspan="2" style="width: 100px">
                                                            @sub.RankName
                                                        </td>
                                                        <td></td>
                                                        <td style="width: 150px">
                                                            审批人：
                                                            @if (action == "addReview")
                                                            {
                                                                <input id="per@(sub.ID)" style="width: 80px" class="easyui-combobox" name="per@(sub.ID)"
                                                                       data-options=data-options="@Html.Raw("valueField:'value',textField:'text',url:'/Audit/GetAuditPeo?type=high&detailId="+sub.DocNum+"',panelHeight: 'auto',editable: false, onLoadSuccess: function () {var data =$('#per"+sub.ID+"').combobox('getData');if (data.length > 0) {if("+sub.Reviewer+"!=0){ $('#per"+sub.ID+"').combobox('select',"+sub.Reviewer+");}else{if(data.length==1){ $('#per"+sub.ID+"').combobox('select', data[0].value);}}}}")"/>
                                                            }
                                                            else
                                                            {
                                                                @sub.ReviewerName
                                                            }
                                                        </td>
                                                        <td style="width: 120px">
                                                            审批结果：
                                                            @if (sub.RevState == "0")
                                                            {
                                                                @Html.Raw("未审批")
                                                            }
                                                            else if (sub.RevState == "1")
                                                            {
                                                                @Html.Raw("同意")
                                                            }
                                                            else if (sub.RevState == "2")
                                                            {
                                                                @Html.Raw("驳回")
                                                            }
                                                            else
                                                            {
                                                                @Html.Raw("")
                                                            }
                                                        </td>
                                                        <td>
                                                            审批时间:@sub.RevTime

                                                        </td>
                                                        <td style="width: 150px">
                                                            @if (sub.IsAuth == "1")
                                                            {
                                                                //被授权人:sub.AuthName
                                                            }
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 100px">
                                                            审批意见：
                                                        </td>
                                                        <td style="text-align: left" colspan="4">
                                                            <textarea style="height: 40px; width: 620px" readonly="readonly">@sub.RevAdv</textarea>
                                                        </td>
                                                    </tr>
                                                </table>
                                            }
                                        </td>
                                    </tr>
                                }
                            </table>
                        </div>
                    </form>
                </div>
            </div>
            @if (action == "review")
            {
                <div title="审批意见栏" style="overflow: auto; padding: 10px;">
                    <form id="reviewForm2">
                        <table>
                            <tr>
                                <td style="width: 150px">审批人:@basic.Name</td>
                                @*<td><%--审批结果：<input type="radio" name="radCurrentResult" value="1" />同意<input type="radio" name="radCurrentResult" value="2" />不同意--%></td>*@
                            </tr>
                        </table>
                        <table>
                            <tr>
                                <td style="width: 100px">
                                    审批意见：
                                </td>
                                <td style="text-align: left">
                                    <textarea style="height: 40px; width: 500px" id="txtCurrentAdv" name="txtCurrentAdv"> </textarea>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            }
        </div>
    </div>
</body>
</html>
